<template>
  <div>
    <table-container v-bind="state.tableSchema">
      <template v-slot:id="scope">
        {{ +scope.row.id }}
      </template>
      <template v-slot:post_title="scope">
        {{ scope.row.post_title }}
      </template>
    </table-container>
  </div>
</template>

<script lang="ts" setup>
import { Delete, Download, Plus, Refresh, Search, Upload } from '@element-plus/icons-vue';
import { FormDataRowType } from 'types/form';
import { TableDataTypeRow, TableSearchSchemaRowType } from 'types/table';
import { reactive, ref } from 'vue';
let state = reactive<any>({})

const resetSearch = () => {
  console.log(`output-`)
}

const search = () => {
  console.log('自定义函数');
}

const domr = ref()


state.tableSchema = {
  url: '/app/news/list',
  // 自定义配置
  config: {
    loading: true,
  },
  //自定义查询参数
  params: {  }, 
  fields: [
    { type: 'index', field: '', label: '序号', width: 50 },
    { field: 'id', label: '编号' },
    { field: 'title', label: '商品名', width:200, showOverflowTooltip: true },
    { field: 'sub_title', label: '型号', showOverflowTooltip: true },
    { field: 'price', label: '价格', showOverflowTooltip: true },
    { field: 'create_time', label: '时间', width: 180 },
  ] as TableDataTypeRow[],
  searchFormSchema: [
    { field: 'post_title', type: 'input', label: '标题',value:'新冠病毒' },
    // { field: 'create_time', type: 'date', label: '链题标接', value: '2022-12-21' },
  ] as TableSearchSchemaRowType[],
  formSchema: [
    { field: 'post_title', type: 'input', label: '标题',value:'新冠病毒' },
    { field: 'hot', type: 'input', label: '热度', value: '420119' },
    { field: 'post_url', type: 'input', label: '链接' },
  ] as FormDataRowType[],
  searchActions: [
    { type: 'reset', title: '重置', style: 'primary', icon: 'Refresh' },
    { type: 'search', title: '搜索', style: 'primary', icon: 'Search' },
  ],
  tableActions: [
    { type: 'import', title: '导入', style: '', icon: 'Upload' },
    { type: 'export', title: '导出', style: '', icon: 'Download' },
    { type: 'add', title: '新增', style: 'primary', icon: 'Plus' },
    { type: 'delete', title: '删除', style: 'danger', icon: 'Delete' }
  ],
  tableRowActions: [
    { type: 'update', title: '修改', style: 'text' },
    { type: 'delete', title: '删除', style: 'text' }

  ],
  formActions: [
    { type: 'reset', title: '重置', icon: 'Refresh' },
    { type: 'submit', title: '提交', icon: 'Search' },

  ],
  uploadOptions: {
    limit: 1,
    accept: '.jpg,.png',
    headers: {}
  }
}



</script>


<style lang="scss" scoped></style>